$(document).on("pageInit", "#page_mycarlist2", function(e, pageId, $page) {
	   setTimeout(function(){$.showPreloader();},1)
       my.givetitle('爱车管理');
       my.getlogintiaozhuan();
	   var showOwnerSwiper = new Swiper('.swiper-container',{
                                                       pagination : '.swiper-pagination',
                                                       paginationElement : 'li',
       })
	   $('.css_car_add').click(function(){
           $.router.loadPage(' checkCar.html');
       });
       var key=my.get_key(my.getCookie('token'));
       var info_carManger={'u_userid':my.getCookie('id') };
           info_carManger=JSON.stringify(info_carManger);
           info_carManger=my.cryptoASEencrypt(info_carManger,key);
           $.ajax({
              type:"post",
              url:api.usercarlist,
              data:{'api_value':info_carManger},
              error:function(){
                 $.hidePreloader();
                 $.toast("请求失败，请刷新重试");
              },
              success:function(data){
              if(data.match("err_code")!=null){
            	 $.hidePreloader();
                switch(JSON.parse(data).err_code)
                 {
                    case 40003:
                        my.tokenExpire();
                        break;
                    case 50070:
                       $(".car_counts").text(0);
                        break;
                    default:
                        $.toast(JSON.parse(data).err_msg);

                 }
               }
               else
               {
                   data=JSON.parse(data);
                   data=JSON.parse(my.cryptoASEdencrypt(data.data,key));
                   console.log(data);
                   //循环输出车辆
                   $('.sscript_car_list').empty();
                   $(".car_counts").text(data[0].carlist_num);
                   for(i=0;i<data.length;i++){
                      var state_doc='认证中';
                      var state_doc_color = 'color:#F1751A';
                      if(data[i].auditresult_state==1){
                          state_doc='<span class="icon icon-check"></span>&nbsp;认证通过';
                          var state_doc_color = 'color:green';
                          var  auditresult_state_html = '<div class="list_btn_b clearfix"><div class="list_btn_left" style="background-color:#0894EC;"><a href="#" class="yuyue_parking" style="color: #ffffff">预约机场停泊</a></div><div class="list_btn_right" style="background-color:#0894EC;"><a href="#" class="share_zhuanqian"  style="color: #ffffff">分享赚取收益</a></div> </div>';
                       }
                      if(data[i].auditresult_state==2){
                          var state_doc_color = 'color:red';
                          state_doc='认证失败：'+data[i].resultreason;
                          var  auditresult_state_html = '<div class="list_btn_a" style="background-color:#0894EC;"><a href="#" class="yuyue_parking"  style="color: #ffffff">预约机场停泊</a></div>';
                       }
                       if(data[i].auditresult_state==3){
                           var state_doc_color = 'color:red';
                           state_doc='未认证&nbsp;<span class="icon icon-right" style="padding-top: -0.6rem"></span>';
                           var  auditresult_state_html = '<div class="list_btn_a" style="background-color:#0894EC;"><a href="#" class="yuyue_parking"  style="color: #ffffff">预约机场停泊</a></div>';
                        }
                        if(data[i].auditresult_state==0){
                           var  auditresult_state_html = '<div class="list_btn_a" style="background-color:#0894EC;"><a href="#" class="yuyue_parking"  style="color: #ffffff">预约机场停泊</a></div>';
                        }

                  // var list = '<div class="card"><div class="card-header"><span>'+ data[i].car_plate +'</span><span class="css_car_upd script_car_edit" data-ids="'+ data[i].usercar_id +'">修改</span>'
                    //           + '<img src="/h5car/img/icon/ok.png" style="width:15px;margin: 0 5px -2px 0;'+ none_in +'"><span class="css_auditsttus"> '+ state_doc +'</span> <span class="css_car_status">'+data[i].car_state+'</span> </div> <div style="clear: both;"></div>'
                      //         +'<div class="card-content"> <div class="card-content-inner" style="height: 3.5rem"> <div class="css_detail_1"> <div>违章</div>'
                        //       + '<div class="css_center_text">'+data[i].illegal_count+'</div> </div> <div class="css_detail"> <div>罚款(元)</div> <div class="css_center_text">'+data[i].illegal_money+'</div> </div>'
                          //     +'<div  class="css_detail"> <div>扣分</div> <div class="css_center_text">'+data[i].illegal_fen+'</div> </div> <div  class="css_detail"> <div>下次年检</div>'
                            //   +'<div class="css_center_text">'+data[i].year_checktime+'</div> </div> <div  class="css_detail"> <div>下次保养</div> <div class="css_center_text">'+data[i].maintain_time+'</div>'
                            //   +'</div> </div> </div> <div class="card-footer">'
                             //  +'<span class="css_car_f"><a href='+parkIndexUrl+'  style="color: #ffffff">预约机场停泊</a></span> <span class="css_car_f"><a href='+carRentalUrl+'  style="color: #ffffff">分享赚取收益</a></span> </div> </div>';

                      var list = '<div class="myCarList clearfix" data-carsid='+data[i].usercar_id +'><div class="list_head script_caredit" data-carsids='+data[i].usercar_id +'><span class="list_head_t">'
                        +'<span class="iconfont icon-nav-qiche"></span>'+ data[i].car_plate +'</span><span class="icon icon-edit"></span><span class="list_head_s">'+data[i].car_state+'</span><span class="list_head_state" style='+state_doc_color+'>'+ state_doc +'</span></div>'
                        +'<div class="list_center clearfix script_caredit" data-carsids='+data[i].usercar_id +'><div class="list_center_list"><div class="list_center_list_top">违章</div><div class="list_center_list_bottom">'+data[i].illegal_count+'</div>'
                        +'</div><div class="list_center_list"><div class="list_center_list_top">罚款(元)</div><div class="list_center_list_bottom">'+data[i].illegal_money+'</div>'
                        +'</div><div class="list_center_list"><div class="list_center_list_top">下次年检</div><div class="list_center_list_bottom">'+data[i].year_checktime+'</div>'
                        +'</div><div class="list_center_list"><div class="list_center_list_top">下次保养</div><div class="list_center_list_bottom">'+data[i].maintain_time+'</div>'
                        +'</div></div>'+auditresult_state_html+'</div>';

                       $('.sscript_car_list').append(list);
                }
                   $.hidePreloader();

               }
                 //车辆编辑
               $('.script_caredit').click(function(){
                   sessionStorage.car_id=$(this).attr('data-carsids')
                   $.router.load(carEditUrl,true);
              });
            //汽车泊车
              $('.yuyue_parking').click(function(){
                  $.router.load(parkIndexUrl,true);
              });

              $('.share_zhuanqian').click(function(){
                 $.router.load(carRentalUrl,true);
              });
              $('.script_caidan').on('click', function () {
                var buttons1 = [
                    {
                        text: '代缴罚款'
                    },
                    {
                        text: '代办驾照'
                    }
                ];
                var buttons2 = [
                    {
                        text: '取消',
                        bg: 'danger'
                    }
                ];
                var groups = [buttons1, buttons2];
                $.actions(groups);
            });
        }
    });

})